using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domep.Server.BusinessObjects;
using Domep.Server.Kernel.ApplianceCommunication;

namespace Domep.Server.Kernel.DBCommunication
{
    public class OrderChecker
    {
        private ServerContext db = new ServerContext();
        public OrderInfo CheckCompatibility(int orderID, int applianceID)
        {
            //Appliance appliance = db.Appliances.Find(applianceID);
            Appliance appliance = new Appliance();
            if (appliance == null)
                throw new InvalideApplianceException(applianceID.ToString());

            Functionality functionality = appliance.Model.Functionalities.Find(f => f.Id == orderID);
            
            if (functionality == null)
                throw new InvalidFunctionalityException(orderID.ToString());
            
            return new OrderInfo(appliance.IpAdress,functionality.Signature);
        }
    }
}